﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;


namespace FlickrDownloadr
{
    public class CommandLink : Button
    {
        [DllImport("user32.dll", CharSet = CharSet.Unicode)]
        static extern IntPtr SendMessage(HandleRef hWnd, UInt32 Msg,IntPtr wParam, string lParam);

        const int BS_COMMANDLINK = 0x0000000E;
        const uint BCM_SETNOTE = 0x00001609;
        const uint BCM_SETSHIELD = 0x0000160C;

        public CommandLink()
        {
            if (System.Environment.OSVersion.Version.Major > 5)
            {
                this.FlatStyle = FlatStyle.System;
            }
        }

        protected override CreateParams CreateParams
        {
            get
            {
                if (System.Environment.OSVersion.Version.Major > 5)
                {
                    CreateParams cp = base.CreateParams;
                    cp.Style |= BS_COMMANDLINK;
                    return (cp);
                }
                else
                {
                    return base.CreateParams;
                }
            }
        }

        private void SetNote(string NoteText)
        {
            SendMessage(new HandleRef(this, this.Handle), BCM_SETNOTE, IntPtr.Zero, NoteText);
        }
    }
}
